﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFP;
using SFP.Audio;
using SFP.CollisionDetection;
using HamsterDelivery.Menus;

namespace HamsterDelivery.LevelStructure.Reactions
{
    public class LevelEndReaction : Reaction
    {
        private HamsterGame game;

        public LevelEndReaction(HamsterGame game)
        {
            this.game = game;
        }

        private void checkPackages()
        {
            if (game.PackageScore == 4)
            {
                Level level = game.Level;
                level.LevelCounter++;

                if (level.LevelCounter <= 2)
                {
                    level.loadLevel(level.LevelCounter);
                }
                else
                {
                    game.InGame = false;
                    game.InMenu = true;
                    game.Level.LevelCounter = 1;
                    AudioPlayer.stopAll();
                    MenuManager.ActiveMenu = MenuManager.StartMenu;
                }
            }
        }

        protected override void fromBeneath(CollisionInfo collisionInfo)
        {
            checkPackages();
        }

        protected override void fromAbove(CollisionInfo collisionInfo)
        {
            checkPackages();
        }

        protected override void fromLeft(CollisionInfo collisionInfo)
        {
            checkPackages();
        }

        protected override void fromRight(CollisionInfo collisionInfo)
        {
            checkPackages();
        }

        protected override void touchesTop(CollisionInfo collisionInfo)
        {
        }

        protected override void touchesBottom(CollisionInfo collisionInfo)
        {
        }

        protected override void touchesLeft(CollisionInfo collisionInfo)
        {
        }

        protected override void touchesRight(CollisionInfo collisionInfo)
        {
        }
    }
}
